﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HealthSystem1 : MonoBehaviour
{
    public event Action<int> OnHealthChanged;

    private int _health = 100;

    public int Health
    {
        get => _health;
        set
        {
            if (_health != value)
            {
                _health = Mathf.Max(0, value); // 确保血量 >= 0
                OnHealthChanged?.Invoke(_health); // 通知监听者
            }
        }
    }
}